<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>参数复用</title>
</head>

<body>

</body>
<script>
  "use strict"; {
    {
      // 传统的做法
      const url_curring = (protocol, hostname, pathname) => {
        return `${protocol}${hostname}${pathname}`;
      };
      const url = url_curring("https://", "baidu.com", "./dir");
      console.log(url);
    };
    {
      // 柯里化的参数复用
      const url_curring = (protocol) => {
        return (hostname, pathname) => {
          return `${protocol}${hostname}${pathname}`;
        };
      };
      const url_https = url_curring("https://");
      const url1 = url_https("www.baidu.com", "/点赞");
      const url2 = url_https("www.weibo.com", "/关注");
      const url3 = url_https("www.qq.com", "/收藏");

      console.log(url1, url2, url3);
    }
  };
</script>

</html>